Dataset contains 905,257 rows, 51 columns.
## Reading layer `geo_export_bfc6dc33-c815-4ad0-b171-d686045a297f' from data source `/Users/justinong415/Documents/traffic_stops_project/geo_export_bfc6dc33-c815-4ad0-b171-d686045a297f.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 117 features and 2 fields
## Geometry type: POLYGON
## Dimension: XY
## Bounding box: xmin: -122.5149 ymin: 37.70809 xmax: -122.357 ymax: 37.8324
## Geodetic CRS: GCS_WGS84_DD
## `summarise()` has grouped output by 'month'. You can override using the
## `.groups` argument.
head(traffic_stops)
## # A tibble: 6 × 51
## date time hour day_of_week month year_month year subject_age
## <date> <time> <int> <fct> <fct> <date> <dbl> <dbl>
## 1 2014-08-01 01'00" 0 Fri Aug 2014-08-01 2014 NA
## 2 2014-08-01 01'00" 0 Fri Aug 2014-08-01 2014 NA
## 3 2014-08-01 15'00" 0 Fri Aug 2014-08-01 2014 NA
## 4 2014-08-01 18'00" 0 Fri Aug 2014-08-01 2014 NA
## 5 2014-08-01 19'00" 0 Fri Aug 2014-08-01 2014 NA
## 6 2014-08-01 30'00" 0 Fri Aug 2014-08-01 2014 NA
## # ℹ 43 more variables: subject_race <fct>, subject_sex <fct>, outcome <fct>,
## # search_conducted <lgl>, reason_for_stop <fct>, city_population <dbl>,
## # officers <dbl>, sunrise <time>, sunset <time>, mayor <fct>,
## # district_attorney <fct>, police_chief <fct>, officers_per_capita <dbl>,
## # daylight_or_nighttime <fct>, geometry <POINT [°]>, longitude <dbl>,
## # latitude <dbl>, location <chr>, neighborhood <fct>, other <int>,
## # aapi <int>, hispanic <int>, black <int>, white <int>, female <int>, …
head(long_district_attorneys)
## # A tibble: 6 × 5
## neighborhood district_attorney da_avg_stops longitude latitude
## <fct> <chr> <dbl> <dbl> <dbl>
## 1 Alamo Square kamala_stops 296 -122. 37.8
## 2 Alamo Square gascon_stops 168 -122. 37.8
## 3 Anza Vista kamala_stops 65 -122. 37.8
## 4 Anza Vista gascon_stops 67 -122. 37.8
## 5 Apparel City kamala_stops 169 -122. 37.7
## 6 Apparel City gascon_stops 276 -122. 37.7
What is the veil of darkness test?
##
## Call:
## lm(formula = black ~ nighttime, data = traffic_stops)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.1880 -0.1880 -0.1539 -0.1539 0.8461
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.1538721 0.0005141 299.32 <2e-16 ***
## nighttime 0.0341489 0.0007965 42.87 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3736 on 905145 degrees of freedom
## (484 observations deleted due to missingness)
## Multiple R-squared: 0.002027, Adjusted R-squared: 0.002026
## F-statistic: 1838 on 1 and 905145 DF, p-value: < 2.2e-16
Regression Model: \(NonWhite Drivers = \beta_0 + \beta_1{Kamala} + \beta_2{OfficersPerCapita} + \beta_3{Night} + \beta_4{Sex} + \epsilon\)
##
## Call:
## lm(formula = non_white ~ kamala + officers_per_capita + nighttime +
## subject_sex, data = traffic_stops)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.6766 -0.5699 0.3489 0.4090 0.5165
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.094518 0.021701 50.435 <2e-16 ***
## kamala 0.004113 0.002464 1.669 0.0951 .
## officers_per_capita -0.148304 0.005843 -25.381 <2e-16 ***
## nighttime 0.041687 0.001047 39.822 <2e-16 ***
## subject_sexmale 0.072677 0.001132 64.177 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4895 on 905142 degrees of freedom
## (484 observations deleted due to missingness)
## Multiple R-squared: 0.01057, Adjusted R-squared: 0.01057
## F-statistic: 2418 on 4 and 905142 DF, p-value: < 2.2e-16
Regression Model: \(Arrests = \beta_0 + \beta_1{Kamala} + \beta_2{Race} + \beta_3{Neighborhood} + \beta_4{Officers per Capita} + \beta_5{Month} + \beta_6{Day of the Week} + \epsilon\)
## # A tibble: 36 × 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 kamala 0.00620 0.000587 10.5 5.15e- 26
## 2 subject_raceasian/pacific islander -0.000991 0.000465 -2.13 3.32e- 2
## 3 subject_racehispanic 0.0104 0.000506 20.6 2.50e- 94
## 4 subject_raceblack 0.0141 0.000486 29.0 5.14e-185
## 5 subject_racewhite 0.00138 0.000407 3.40 6.72e- 4
## 6 neighborhoodApparel City -0.00494 0.00221 -2.23 2.55e- 2
## 7 neighborhoodBret Harte 0.00564 0.00217 2.59 9.55e- 3
## 8 neighborhoodCayuga 0.00871 0.00176 4.94 7.99e- 7
## 9 neighborhoodDiamond Heights 0.0324 0.00457 7.09 1.37e- 12
## 10 neighborhoodFairmount 0.0101 0.00340 2.97 2.96e- 3
## # ℹ 26 more rows
## # A tibble: 118 × 2
## neighborhood avg_stops
## <fct> <dbl>
## 1 South of Market 7116
## 2 Mission 5316
## 3 Inner Richmond 3458
## 4 Tenderloin 3450
## 5 Bayview 2824
## 6 Outer Sunset 2367
## 7 Downtown / Union Square 2130
## 8 Parkside 1771
## 9 Lower Nob Hill 1570
## 10 Cayuga 1567
## # ℹ 108 more rows